package com.baidu.acg.industry.bigdata.utils;

import lombok.extern.slf4j.Slf4j;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

@Slf4j
public class DataUtils {
    public static String minioFolderPathSub(String minioPathFolder) {
        // 找到第一个和第二个下划线的位置
        Pattern pattern = Pattern.compile("([a-zA-Z0-9]+_[a-zA-Z0-9]+)$");
        Matcher matcher = pattern.matcher(minioPathFolder);
        String taskIdWithUuid = "";
        if (matcher.find()) {
            taskIdWithUuid = matcher.group(1);
        } else {
            System.out.println("未找到匹配内容");
        }
        return taskIdWithUuid;
    }

    public static String subStringUrl(String modelPath) {
        try {
            URL url = new URL(modelPath);
            return url.getPath(); // 直接获取路径部分
        } catch (MalformedURLException e) {
            log.error("URL格式错误：" + e.getMessage());
            e.getMessage();
        }
        return "";
    }

}
